#ifndef APP_H_
#define APP_H_

#define APP1_START_ADDR  0x9000
#define APP2_START_ADDR  0x14000

// app1 reset handler
#define APP1_ADDR_P     APP1_START_ADDR + 0x80

#define APP1_RTC_P      APP1_START_ADDR
#define APP1_ADC_P      APP1_START_ADDR + 0x50
#define APP1_DAC_P      APP1_START_ADDR + 0x54
#define APP1_I2C_P      APP1_START_ADDR + 0x58
#define APP1_UART0_P    APP1_START_ADDR + 0x5c
#define APP1_UART1_P    APP1_START_ADDR + 0x60
#define APP1_GPIO_P     APP1_START_ADDR + 0x64
#define APP1_SPIM0_P    APP1_START_ADDR + 0x68
#define APP1_SPIM1_P    APP1_START_ADDR + 0x6c
#define APP1_TA_OVF_P   APP1_START_ADDR + 0x70
#define APP1_TA_CMP_P   APP1_START_ADDR + 0x74
#define APP1_TB_OVF_P   APP1_START_ADDR + 0x78
#define APP1_TB_CMP_P   APP1_START_ADDR + 0x7c


// app2 reset handler
#define APP2_ADDR_P     APP2_START_ADDR + 0x80

#define APP2_RTC_P      APP2_START_ADDR
#define APP2_ADC_P      APP2_START_ADDR + 0x50
#define APP2_DAC_P      APP2_START_ADDR + 0x54
#define APP2_I2C_P      APP2_START_ADDR + 0x58
#define APP2_UART0_P    APP2_START_ADDR + 0x5c
#define APP2_UART1_P    APP2_START_ADDR + 0x60
#define APP2_GPIO_P     APP2_START_ADDR + 0x64
#define APP2_SPIM0_P    APP2_START_ADDR + 0x68
#define APP2_SPIM1_P    APP2_START_ADDR + 0x6c
#define APP2_TA_OVF_P   APP2_START_ADDR + 0x70
#define APP2_TA_CMP_P   APP2_START_ADDR + 0x74
#define APP2_TB_OVF_P   APP2_START_ADDR + 0x78
#define APP2_TB_CMP_P   APP2_START_ADDR + 0x7c

void app_init();

//app 1
void (*app1_p)();
void (*app1_isr_rtc_p)();
void (*app1_isr_adc_p)();
void (*app1_isr_dac_p)();
void (*app1_isr_i2c_p)();
void (*app1_isr_uart0_p)();
void (*app1_isr_uart1_p)();
void (*app1_isr_gpio_p)();
void (*app1_isr_spim0_p)();
void (*app1_isr_spim1_p)();
void (*app1_isr_ta_ovf_p)();		
	
void (*app1_isr_tb_ovf_p)();
void (*app1_isr_tb_cmp_p)();
		

void (*app2_p)();
void (*app2_isr_rtc_p)();
void (*app2_isr_adc_p)();
void (*app2_isr_dac_p)();
void (*app2_isr_i2c_p)();
void (*app2_isr_uart0_p)();
void (*app2_isr_uart1_p)();
void (*app2_isr_gpio_p)();
void (*app2_isr_spim0_p)();
void (*app2_isr_spim1_p)();
void (*app2_isr_ta_ovf_p)();		
		
void (*app2_isr_tb_ovf_p)();
void (*app2_isr_tb_cmp_p)();
	
		
#define app1() ((*app1_p)())
#define app1_isr_rtc() ((*app1_isr_rtc_p)())
#define app1_isr_adc() ((*app1_isr_adc_p)())
#define app1_isr_dac() ((*app1_isr_dac_p)())
#define app1_isr_i2c() ((*app1_isr_i2c_p)())
#define app1_isr_uart0() ((*app1_isr_uart0_p)())
#define app1_isr_uart1() ((*app1_isr_uart1_p)())
#define app1_isr_gpio() ((*app1_isr_gpio_p)())
#define app1_isr_spim0() ((*app1_isr_spim0_p)())
#define app1_isr_spim1() ((*app1_isr_spim1_p)())
#define app1_isr_ta_ovf() ((*app1_isr_ta_ovf_p)())
//#define app1_isr_ta_cmp() ((*app1_isr_ta_cmp_p)())
#define app1_isr_tb_ovf() ((*app1_isr_tb_ovf_p)())
#define app1_isr_tb_cmp() ((*app1_isr_tb_cmp_p)())


#define app2() ((*app2_p)())
#define app2_isr_rtc() ((*app2_isr_rtc_p)())
#define app2_isr_adc() ((*app2_isr_adc_p)())
#define app2_isr_dac() ((*app2_isr_dac_p)())
#define app2_isr_i2c() ((*app2_isr_i2c_p)())
#define app2_isr_uart0() ((*app2_isr_uart0_p)())
#define app2_isr_uart1() ((*app2_isr_uart1_p)())
#define app2_isr_gpio() ((*app2_isr_gpio_p)())
#define app2_isr_spim0() ((*app2_isr_spim0_p)())
#define app2_isr_spim1() ((*app2_isr_spim1_p)())
#define app2_isr_ta_ovf() ((*app2_isr_ta_ovf_p)())
//#define app2_isr_ta_cmp() ((*app2_isr_ta_cmp_p)())
#define app2_isr_tb_ovf() ((*app2_isr_tb_ovf_p)())
#define app2_isr_tb_cmp() ((*app2_isr_tb_cmp_p)())

#endif